Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add send event method customization #68

Merged
merged 3 commits into from
Jul 23, 2023

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Jul 15, 2023

🧿 Current issues / What's wrong ?

All http webhooks events are now sent via a POST method, and GET is not supported.

This is the first step to get rid of this hardcoded piece of code: https://github.com/snapshot-labs/snapshot-webhook/blob/master/src/events.ts#L110-L115 , which is raising a lot of errors when sequencer has issues.

Fix #56

💊 Fixes / Solution

Support GET, HEAD and all other methods

🚧 Changes

  • Add a new column for the method in the database. (run ALTER TABLE subscribers ADD COLUMN method VARCHAR(5) NOT NULL DEFAULT 'POST';)
  • Send webhook events depending on the subscriber chosen method

🛠️ Tests

@sentry-io
Copy link

sentry-io bot commented Jul 15, 2023

Sentry issue: SNAPSHOT-WEBHOOK-1

@ChaituVR
Copy link
Member

But why do we need to add support for the get method 🤔 anyone requested this? to trigger score calculation?

event.token = sha256(`${to}${serviceEventsSalt}`);
event.secret = sha256(`${to}${serviceEventsSalt}`);
const headerSecret = sha256(`${to}${process.env.SERVICE_EVENTS_SALT}`);
const url = to.replace('[PROPOSAL-ID]', event.id.split('/')[1]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this URL format is only useful for our case, others may not use it or we need to find a way to send event type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. We can and should add support to inject all the other parameters send in the post body as a query params placeholder. And we should also support head request

@ChaituVR
Copy link
Member

@aurelianoB What do you think about this?

@ChaituVR ChaituVR merged commit 05c3d87 into master Jul 23, 2023
@ChaituVR ChaituVR deleted the add-new-subscriber-send-method branch July 23, 2023 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: customize webhooks methods and url
2 participants